package com.xyht.sca_s.student_manage_system.common.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.common.util.DynamicSchedulingTaskUtil;
import com.xyht.sca_s.student_manage_system.modules.attendance.entity.SmsSchedulingTask;
import com.xyht.sca_s.student_manage_system.modules.attendance.mapper.SmsSchedulingTaskMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

import java.util.Date;
import java.util.List;

import static com.xyht.sca_s.student_manage_system.common.constant.CloseFlagConstant.IS_CLOSE_FALSE;
import static com.xyht.sca_s.student_manage_system.common.constant.CommonConstant.POOL_SIZE;

@Component
public class DynamicTaskConfig {
    // 定义线程池大小为10
//    private static final int POOL_SIZE = 10;

    // 定义一个Bean方法，返回一个ThreadPoolTaskScheduler对象
    @Bean
    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
        // 创建一个ThreadPoolTaskScheduler对象
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        // 设置线程池大小为10
        scheduler.setPoolSize(POOL_SIZE);
        // 设置线程名前缀为task-
        scheduler.setThreadNamePrefix("schedule-");
        // 设置异常处理器为打印日志
        scheduler.setErrorHandler(t -> System.out.println(t.getMessage()));
        // 返回scheduler对象
        return scheduler;
    }

}
